package com.example.yunJie.digitalSentry.mapper.one;


import com.example.yunJie.digitalSentry.entity.PersonalEntity;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.io.Serializable;
import java.util.List;

public interface PersonalMapper {
//    @Insert("<script>insert into sz_personal(personalId,personalName,personalCardNumber,personalPhoto,marketId,postId)\n" +
//            "        values(#{personalId},#{personalName},#{personalCardNumber},#{personalPhoto},#{marketId},#{postId})</script>")
    int insert(PersonalEntity personalEntity);

//    @Update("<script>update sz_personal\n" +
//            "        <trim prefix=\"SET\" suffixOverrides=\",\">\n" +
//            "            <if test=\"personalId != null\">personalId = #{personalId},</if>\n" +
//            "            <if test=\"personalName != null\">personalName = #{personalName},</if>\n" +
//            "            <if test=\"personalCardNumber != null\">personalCardNumber = #{personalCardNumber},</if>\n" +
//            "            <if test=\"personalPhoto != null\"> personalPhoto = #{personalPhoto},</if>\n" +
//            "            <if test=\"marketId != null\">marketId = #{marketId},</if>\n" +
//            "            <if test=\"postId != null\">postId = #{postId},</if>\n" +
//            "\n" +
//            "        </trim>\n" +
//            "        where personalName = #{personalName}</script>")
    int update(PersonalEntity personalEntity);

//    @Delete("<script>delete from sz_personal where id = #{Id}</script>")
    int deleteById(Serializable id);

//    @Delete("<script> delete from sz_personal where id in\n" +
//            "        <foreach collection=\"array\" item=\"id\" open=\"(\" separator=\",\" close=\")\">\n" +
//            "            #{id}\n" +
//            "        </foreach></script>")
    int deleteIdList(List<Integer> idList);

//    @Select("<script> select  personalId,personalName,personalCardNumber,personalPhoto,marketId,postId\n" +
//            "        from sz_personal\n" +
//            "        where id = #{id}</script>")
    PersonalEntity findId(String id);

//    @Select("<script>select * from sz_personal\n" +
//            "        left join sz_post on sz_post.id = sz_personal.postId\n" +
//            "        LEFT JOIN sz_market on sz_personal.marketId = sz_market.id\n" +
//            "        <where>\n" +
//            "            <if test=\"marketName != null and marketName != ''\">and sz_personal.marketId = (  SELECT sz_market.id from sz_market where sz_market.marketName = #{marketName})</if>\n" +
//            "            <if test=\"postName != null and postName != ''\"> and  sz_personal.postId = ( SELECT sz_post.id FROM sz_post where sz_post.postName = #{postName})</if>\n" +
//            "        </where></script>")
    List<PersonalEntity> findAll(PersonalEntity personalEntity);
//    @Select("<script>select * from sz_personal\n" +
//            "        <where>\n" +
//            "            <if test=\"personalName != null and personalName != ''\">personalName like concat('%', #{personalName}, '%')</if>\n" +
//            "        </where></script>")
    PersonalEntity findByPersonalName(String s);

    //根据市场查找该市场下所有人员
//    @Select("<script> SELECT sz_personal.personalName FROM sz_personal where sz_personal.marketId = (\n" +
//            "            SELECT sz_market.marketId FROM sz_market where sz_market.marketName = #{marketName}\n" +
//            "        )</script>")
    List<PersonalEntity> findByMarketName(String marketName);

    List<PersonalEntity> findByName(PersonalEntity personalEntity);


}
